<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	签到记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$return['params']=array();	
	//会员ID
	if(!empty($_RQ['mid'])){
		$params['mid']=intval($_RQ['mid']);
		$return['params']['mid']=$_RQ['mid'];
	}
	//type
	$params['type']=intval($_RQ['type']);
	$return['params']['type']=$_RQ['type'];
	//时间范围
	if(!empty($_RQ['tstart']) && $_RQ['tstart'] !='1970-01-01 08:00'){
		$tstart=strtotime($_RQ['tstart']);
		$return['params']['tstart']=trim($_RQ['tstart']);
	}
	if(!empty($_RQ['tend']) && $_RQ['tend'] !='1970-01-01 08:00'){
		$tend=strtotime($_RQ['tend']);
		$return['params']['tend']=trim($_RQ['tend']);
	}
	if($tstart && $tend){
		$params['createtime between']=array($tstart,$tend);
	}elseif($tstart){
		$params['createtime >']=$tstart;
	}elseif($tend){
		$params['createtime <']=$tend;
	}
	$parameter=array('params'=>$params,'limit'=>array($pindex,$psize));
	$orderby='id desc';
	$list=pdo_getslice('jy_yiliao_sign',$params,array($pindex,$psize),$total,array('mid','createtime'),'',$orderby);
	if($list){
		foreach($list as &$log){
			$log['date']=date('Y-m-d',$log['createtime']);
			$member=model('core/member')->detail($item['mid'],array('credit1','credit2','mobile','groupid','avatar','nickname'));
			$item['member']=$member;
			if($item['type']==0){
				$item['username']=pdo_getcolumn('jy_yiliao_user',array('id'=>$item['user_id'],'uniacid'=>$_SESSION['uniacid']),'name');
			}else{
				$item['username']=pdo_getcolumn('jy_yiliao_worker',array('id'=>$item['user_id'],'uniacid'=>$_SESSION['uniacid']),'name');
			}
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'签到记录'),
		),
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'mid','title'=>'会员ID','type'=>'string'),
			array('name'=>'username','title'=>'姓名','type'=>'string'),
			array('name'=>'member','title'=>'粉丝信息','type'=>'member'),
			array('name'=>'date','title'=>'签到日期','type'=>'string'),
			array('name'=>'createtime','title'=>'签到时间','type'=>'time'),
		)),
		'search_one'=>array('name'=>'nickname','add'=>false),
	);
	$return['htmls']=$htmls;
	exi($return);
}